package com.sz.mes.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.diboot.core.util.BeanUtils;
import com.sz.mes.entity.CustomerType;
import com.sz.mes.mapper.CustomerTypeMapper;
import com.sz.mes.service.CustomerTypeService;
import com.sz.mes.service.impl.BaseCustomServiceImpl;
import com.sz.mes.vo.CustomerTypeDetailVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.io.Serializable;

/**
* 客户类型相关Service实现
* @author hem
* @version 1.0
* @date 2023-04-04
 * Copyright © szhs
*/
@Service
@Slf4j
public class CustomerTypeServiceImpl extends BaseCustomServiceImpl<CustomerTypeMapper, CustomerType> implements CustomerTypeService {

    @Override
    public List<CustomerTypeDetailVO> getCustomerTypeTree(Serializable rootId) {
        LambdaQueryWrapper<CustomerType> queryWrapper = new LambdaQueryWrapper<CustomerType>();
        queryWrapper.orderByAsc(CustomerType::getId);
        List<CustomerType> customerTypeList = getEntityList(queryWrapper);
        List<CustomerTypeDetailVO> customerTypeDetailVOList = BeanUtils.convertList(customerTypeList, CustomerTypeDetailVO.class);
        return BeanUtils.buildTree(customerTypeDetailVOList, rootId);
    }

}
